package com.heima.article.controllerv1;


import com.heima.article.service.ArticleService;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.article.pojos.ApArticle;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/api/v1/article")
public class ArticleController {


    @Autowired
    private ArticleService articleService;

    @PostMapping("load")
    public ResponseResult<List<ApArticle>> load(@RequestBody ArticleDto articleDto){
        ResponseResult<List<ApArticle>> apArticleList=  articleService.load(articleDto);
        return  apArticleList;
    }
    @PostMapping("loadmore")
    public ResponseResult<List<ApArticle>> loads(@RequestBody ArticleDto articleDto){
        ResponseResult<List<ApArticle>> apArticleList=  articleService.loads(articleDto);
        return  apArticleList;
    }
    @PostMapping("loadnew")
    public ResponseResult<List<ApArticle>> loadn(@RequestBody ArticleDto articleDto){
        ResponseResult<List<ApArticle>> apArticleList=  articleService.load(articleDto);
        return  apArticleList;
    }
}
